package com.dbappsecurity.bifrost.di.module;

import android.content.SharedPreferences;
import com.dbappsecurity.bifrost.BifrostApp;
import com.dbappsecurity.network.Thunder;
import com.dbappsecurity.network.client.NetworkClient;
import com.dbappsecurity.network.client.interceptor.HeaderInterceptor;
import dagger.Module;
import dagger.Provides;
import javax.inject.Singleton;

/**
 * Created by Arirus on 2018/5/11.
 */

@Module
public class AppModule {

  @Provides
  @Singleton
  Thunder getApiClient() {
    NetworkClient client = NetworkClient.newInstance(NetworkClient.Logger.BASIC);
    HeaderInterceptor interceptor = new HeaderInterceptor();
    client.replaceInterceptor(interceptor);
    return new Thunder.Builder().baseUrl("http://www.baidu.com").networkClient(client).build();
  }

  @Provides
  @Singleton
  SharedPreferences getPrefrences(BifrostApp appParent) {
    return appParent.getSharedPreferences(appParent.getPackageName(), 0);
  }
}
